<template>
	<view class="content">
		<empty v-if="alarmList.length == 0"></empty>
		<view style="width:100%;height:100%" v-else>
			<view class="roleCon" v-for="(item,index) in alarmList" :key="index">
				<view class="community-title">
					<view style="font-size: 30upx;font-weight: bolder;width: 75%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{item.place}}</view>
					<view>
						<text class="yticon icon-you" @click="navTo('/package_isp/pages/alarm/alarmDetail',item)" style="margin-right: 26upx;font-size: 30upx;font-weight: bold;"></text>
					</view>
				</view>
				<view class="list-cell">
					<view class="list-cell-item">
						<view class="item-title">报警人：</view>
						<view class="item-info">{{item.contactsName}}</view>
					</view>
					<view class="list-cell-item">
						<view class="item-title">联系方式：</view>
						<view class="item-info">{{item.contactsPhone}}</view>
					</view>
					<view class="list-cell-item">
						<view class="item-title">报警类型：</view>
						<view class="item-info">{{item.tagName}}</view>
					</view>
					<view class="list-cell-last">
						<view class="item-title">详情描述：</view>
						<view class="item-info">{{item.content}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import empty from "@/components/empty";
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				alarmList: [],
				communityId: this.$api.util.getAreaCode(),
				page: 1
			}
		},
		onLoad() {
			this.initData()
		},
		components: {
			empty
		},
		computed: {
			...mapState(['hasLogin', 'userInfo'])
		},
		methods: {
			navTo(url, item) {
				uni.navigateTo({
					url: url + "?alarmId=" + item.eventId
				})
			},
			initData() {
				let params = {
					"areaCode": this.communityId,
					"userId": this.userInfo.userUuid,
					"page": this.page,
					"rows": 10,
					"tagType": "ALARM"
				}
				this.$api.request.queryEnventList(params, (res) => {
					if (res.body.status.statusCode == 0) {
						this.alarmList = res.body.data.list
					} else {
						uni.showToast({
							title: "查询失败",
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		width: 100%;
		height: 100%;
		position: relative;
		background-color: $page-color-base;
	}

	.content {
		width: 100%;
		height: 100%;
		overflow: auto;
	}

	.roleCon {
		width: calc(100% - 40upx);
		margin: 20upx;
		background-color: white;
		border-radius: 20upx;
		overflow: hidden;
	}

	.community-title {
		padding-left: 40upx;
		height: 90upx;
		color: white;
		background: linear-gradient(to right, #00abef, #7ddcef);
		line-height: 90upx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		letter-spacing: 2upx;
	}


	.list-cell {
		padding: 20upx 30upx;

		.list-cell-item {
			padding: 25upx 0;
			border-bottom: 1px solid #e9eef5;
			display: flex;
			flex-direction: row;
			justify-content: space-between;

			.item-title {
				font-size: 28upx;
				text-align: left;
				margin-left: 20upx;
			}

			.item-info {
				font-size: 24upx;
				text-align: right;
				margin-right: 20upx;
			}
		}

		.list-cell-last {
			padding: 25upx 0;
			display: flex;
			flex-direction: row;
			justify-content: space-between;

			.item-title {
				font-size: 28upx;
				text-align: left;
				margin-left: 20upx;
			}

			.item-info {
				font-size: 24upx;
				text-align: right;
				margin-right: 20upx;
				width: 70%;
			}
		}
	}

	.button_class {
		position: fixed;
		z-index: 90;
		bottom: 40upx;
		margin-top: 20upx;
		width: 80%;
		margin-left: 10%;
		height: 80upx;
		line-height: 80upx;
		border-radius: 40upx;
		background-color: #1fb0fe !important;
		color: white
	}

	.icon {
		width: 50upx;
		height: 50upx;
	}
</style>
